package web;

import java.util.List;

import vo.Favorite;
import business.FavoriteService;
import business.UserService;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.Preparable;

@SuppressWarnings("unchecked")
public class CopyOfFavoriteAction implements Preparable {
	private FavoriteService service;
	private UserService userService;
	private List<Favorite> favorites;
	private String userId;
	private String itemId;

	public String listFavorite() {
		this.favorites = service.getAllFavorites();
		return Action.SUCCESS;
	}

	public String addFavorite() {
		System.out.println("add fv:" + itemId + "," + userId);
		Favorite fv = new Favorite();
		fv.setItemId(itemId);
		fv.setUser(userService.getAllUsers().get(0));
		service.addFavorite(fv);
		return "favSucc";
	}

	public List<Favorite> getFavorites() {
		return favorites;
	}

	public void prepare() throws Exception {
		// if (id != null)
		// employee = service.find(id);
	}

	public void setFavoriteService(FavoriteService service) {
		this.service = service;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}


	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public void setService(FavoriteService service) {
		this.service = service;
	}

}